﻿namespace Jumpton.SFA.Server.Entity
{
    using System;
    using System.Collections.Generic;
    using System.Text;
    using Jumpton.Persistent;
    using System.Data;


    [RelationMap("BRANDS", typeof(BRANDS), "a")]
    [Relation(RelationJoinType.Left, typeof(CATEGORIES), "b", "a", "CODE", "CATEGORY_CODE")]
    [Relation(RelationJoinType.Left, typeof(MANUFACTURERS), "c", "a", "CODE", "MANUFACTURER_CODE")]

    public class BRANDWITHCATEGORY : ObjectRow
    {

        public BRANDWITHCATEGORY()
        {
        }

        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="dataRow">DataTable 中的一行数据</param>
        /// <param name="objectTable">存储当前对象的数据表格</param>
        public BRANDWITHCATEGORY(System.Data.DataRow dataRow, ObjectTable parent) :
            base(dataRow, parent)
        {
        }

        [Key("ID", true, true, TableAlias = "a")]//主键,对应数据库中的列名
        public int ID
        {
            get { return (int)GetValue("ID"); }
            set { SetValue("ID", value); }
        }

        [Field("CODE", TableAlias = "a")]
        public string BrandCode
        {
            get
            {
                return (System.String)GetValue("BrandCode");
            }
            set
            {
                SetValue("BrandCode", value);
            }
        }

        [Field("NAME", TableAlias = "a")]
        public string BrandName
        {
            get
            {
                return (System.String)GetValue("BrandName");
            }
            set
            {
                SetValue("BrandName", value);
            }
        }

        [Field("CATEGORY_CODE", TableAlias = "a")]
        public string CategoryCode
        {
            get
            {
                return (System.String)GetValue("CategoryCode");
            }
            set
            {
                SetValue("CategoryCode", value);
            }
        }

        [Field("NAME", TableAlias = "b")]
        public string CategoryName
        {
            get
            {
                return (System.String)GetValue("CategoryName");
            }
            set
            {
                SetValue("CategoryName", value);
            }
        }

        [Field("MANUFACTURER_CODE", TableAlias = "a")]
        public string ManuCode
        {
            get
            {
                return (System.String)GetValue("ManuCode");
            }
            set
            {
                SetValue("ManuCode", value);
            }
        }

        [Field("NAME", TableAlias = "c")]
        public string ManuName
        {
            get
            {
                return (System.String)GetValue("ManuName");
            }
            set
            {
                SetValue("ManuName", value);
            }
        }

        [Field("DOMAIN_ID", TableAlias = "a")]
        public decimal DOMAINID
        {
            get
            {
                return (System.Decimal)GetValue("DOMAINID");
            }
            set
            {
                SetValue("DOMAINID", value);
            }
        }

        [Field("LAST_UPDATER")]
        public string LAST_UPDATER
        {
            get
            {
                return (System.String)GetValue("LAST_UPDATER");
            }
            set
            {
                SetValue("LAST_UPDATER", value);
            }
        }

        [Field("LAST_UPDATE_TIME")]
        public long LAST_UPDATE_TIME
        {
            get
            {
                return (long)GetValue("LAST_UPDATE_TIME", DateTime.Now);
            }
            set
            {
                SetValue("LAST_UPDATE_TIME", value);
            }
        }

        [Field("CREATE_TIME")]
        public long CREATETIME
        {
            get
            {
                return (long)GetValue("CREATETIME", DateTime.Now);
            }
            set
            {
                SetValue("CREATETIME", value);
            }
        }

        [Field("ACTIVE")]
        public Boolean ACTIVE
        {
            get
            {
                return (System.Boolean)GetValue("ACTIVE", false);
            }
            set
            {
                SetValue("ACTIVE", value);
            }
        }


        [CalculateField]
        public bool IsValid
        {
            get
            {
                return (System.Boolean)GetValue("ACTIVE", false);
            }
        }
    }
}
